package com.lsl.bhllserver.service.user;

import org.springframework.stereotype.Service;

import com.lsl.bhllserver.entity.*;

@Service
public class LoginService extends UserService {

    // public LoginService() {
    // super();
    // }

    public boolean logincheck(String userid, String password, String role) {
        if (role.equals("admin")) {
            adminDAO.setTypeflag(new Admin());
            Admin flagUser = adminDAO.findByID(userid);
            System.out.println(flagUser.toString());
            if (flagUser.getAdminPassword().equals(password)) {
                return true;
            } else {
                return false;
            }
        } else if (role.equals("customer")) {
            customerDAO.setTypeflag(new Customer());
            Customer flagUser = customerDAO.findByID(userid);
            if (flagUser.getCusPassword().equals(password)) {
                return true;
            } else {
                return false;
            }
        } else if (role.equals("business")) {
            businessDAO.setTypeflag(new Business());
            Business flagUser = businessDAO.findByID(userid);
            if (flagUser.getBusPassword().equals(password)) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

    // System.out.println(adminDAO.test());
    // return false;
}
